using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Reflection;


namespace WebNews
{
    public static class Factory
    {
        public static ISettings CreateGetSettingsObj(GetSettingFrom iGetFrom)
        {
            ISettings result = null;
            switch(iGetFrom)
            {
                case GetSettingFrom.FromDB :
                    result = (ISettings)new GetSettingsItemFromDB(ConfigurationManager.ConnectionStrings["SQLConnString"].ConnectionString);
                    break;
                case GetSettingFrom.FromXML :
                    result = (ISettings)new GetSettingsItemFromXML(ConfigurationManager.ConnectionStrings["XMLConnString"].ConnectionString); 
                    break;
            }

            return result;
        }


        public static WebNews CreateWebNews(string WebNewsNameSpaceName,string WebNewsClassName)
        {
            return (WebNews)Assembly.Load(WebNewsNameSpaceName).CreateInstance(
                WebNewsNameSpaceName+"."+WebNewsClassName);
        }
    }
}
